org.glassfish.jersey.filter.LoggingFilter Java Examples

The following examples show how to use org.glassfish.jersey.filter.LoggingFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TajoRestService.java    From tajo with Apache License 2.0 6 votes vote down vote up
@Override
protected void serviceInit(Configuration conf) throws Exception {
  GsonFeature gsonFeature = new GsonFeature(PlanGsonHelper.registerAdapters());
  
  ClientApplication clientApplication = new ClientApplication(masterContext);
  ResourceConfig resourceConfig = ResourceConfig.forApplication(clientApplication)
      .register(gsonFeature)
      .register(LoggingFilter.class)
      .property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)
      .property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);
  TajoConf tajoConf = (TajoConf) conf;

  InetSocketAddress address = tajoConf.getSocketAddrVar(TajoConf.ConfVars.REST_SERVICE_ADDRESS);
  URI restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null);
  int workerCount = TajoConf.getIntVar(tajoConf, TajoConf.ConfVars.REST_SERVICE_RPC_SERVER_WORKER_THREAD_NUM);
  restServer = NettyRestServerFactory.createNettyRestServer(restServiceURI, resourceConfig, workerCount, false);

  super.serviceInit(conf);
  
  LOG.info("Tajo Rest Service initialized.");
}
 
Example #2
Source File: Server.java    From Stargraph with MIT License 6 votes vote down vote up
void start() {
    try {
        Config config = stargraph.getMainConfig();
        String urlStr = config.getString("networking.rest-url");
        ResourceConfig rc = new ResourceConfig();
        rc.register(LoggingFilter.class);
        rc.register(JacksonFeature.class);
        rc.register(MultiPartFeature.class);
        rc.register(CatchAllExceptionMapper.class);
        rc.register(SerializationExceptionMapper.class);
        rc.register(AdminResourceImpl.class);
        rc.register(new KBResourceImpl(stargraph));
        rc.register(new QueryResourceImpl(stargraph));
        httpServer = GrizzlyHttpServerFactory.createHttpServer(URI.create(urlStr), rc, true);
        logger.info(marker, "Stargraph listening on {}", urlStr);
    } catch (Exception e) {
        throw new StarGraphException(e);
    }
}
 
Example #3
Source File: TestFunctionsResource.java    From tajo with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  InetSocketAddress address = testBase.getTestingCluster().getConfiguration().getSocketAddrVar(ConfVars.REST_SERVICE_ADDRESS);
  restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null);
  functionsURI = new URI(restServiceURI + "/functions");
  restClient = ClientBuilder.newBuilder()
      .register(new GsonFeature(PlanGsonHelper.registerAdapters()))
      .register(LoggingFilter.class)
      .property(ClientProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)
      .property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, true)
      .build();
}
 
Example #4
Source File: WnsClient.java    From java-wns with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static Client createClient(boolean logging, WnsProxyProperties proxyProps) {
    ClientConfig clientConfig = new ClientConfig(JacksonJaxbXMLProvider.class, JacksonJsonProvider.class);

    setProxyCredentials(clientConfig, proxyProps);

    Client client = ClientBuilder.newClient(clientConfig);
    if (logging) {
        LoggingFilter loggingFilter = new LoggingFilter(
                Logger.getLogger(WnsClient.class.getName()), true);

        client = client.register(loggingFilter);
    }
    return client;
}
 
Example #5
Source File: Jersey2Test.java    From jerseyoauth2 with MIT License 5 votes vote down vote up
@Test
public void simpleResourceTest() throws UnsupportedEncodingException
{
	
	ClientIdentifier cliendId = new ClientIdentifier(clientEntity.getClientId(), clientEntity.getClientSecret());
	
	Builder<?> flowBuilder = OAuth2ClientSupport.authorizationCodeGrantFlowBuilder(cliendId, "http://localhost:9998/testsuite/oauth2/auth", "http://localhost:9998/testsuite/oauth2/accessToken");
	OAuth2CodeGrantFlow flow = flowBuilder.scope("test1 test2").redirectUri("http://localhost:9998/testsuite").build();
	String authUrl = flow.start();
	
	Map<String, String> map = retrieveCode(authUrl);
	String code = map.get("code");
	String state = map.get("state"); 
	
	TokenResult tokenResult = flow.finish(code, state);

	client = ClientBuilder.newClient();
	client.register(LoggingFilter.class);
	client.register(OAuth2ClientSupport.feature(tokenResult.getAccessToken()));
	client.register(JacksonFeature.class);
	Invocation.Builder builder = client.target("http://localhost:9998/testsuite/rest/sample/1").request();
	Response response = builder.get();
	
	assertEquals(200, response.getStatus());
	SampleEntity entity = response.readEntity(SampleEntity.class);
	assertNotNull(entity);
}
 
Example #6
Source File: Jersey2Test.java    From jerseyoauth2 with MIT License 5 votes vote down vote up
@Before
public void setUp()
{
	super.setUp();
	ClientConfig clientConfig = new ClientConfig();
	clientConfig.property(ClientProperties.FOLLOW_REDIRECTS, false);
	client = ClientBuilder.newClient(clientConfig);
	client.register(new HttpBasicAuthFilter("manager", "test"));
	client.register(LoggingFilter.class);
	authClient.authorizeClient(clientEntity, "test1 test2");
}
 
Example #7
Source File: JerseyConfig.java    From boot-makeover with Apache License 2.0 5 votes vote down vote up
public JerseyConfig() {
    property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
    property(ServerProperties.JSON_PROCESSING_FEATURE_DISABLE, false);
    property(ServerProperties.MOXY_JSON_FEATURE_DISABLE, true);
    property(ServerProperties.WADL_FEATURE_DISABLE, true);
    register(LoggingFilter.class);
    register(JacksonFeature.class);
    register(HelloService.class);
}
 
Example #8
Source File: ApplicationConfig.java    From gazpachoquest with GNU General Public License v3.0 5 votes vote down vote up
public ApplicationConfig() {
    register(RequestContextFilter.class);
    register(RolesAllowedDynamicFeature.class);
    register(Jackson2Feature.class);

    register(AuthorizationRequestFilter.class);
    register(QuestionnairResource.class);
    register(LoggingFilter.class);

    // register(JerseyResource.class);
    // register(SpringSingletonResource.class);
    // register(SpringRequestResource.class);
    // register(CustomExceptionMapper.class);

}
 
Example #9
Source File: TestSessionsResource.java    From tajo with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  InetSocketAddress address = testBase.getTestingCluster().getConfiguration().getSocketAddrVar(ConfVars.REST_SERVICE_ADDRESS);
  restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null);
  sessionsURI = new URI(restServiceURI + "/sessions");
  restClient = ClientBuilder.newBuilder()
      .register(new GsonFeature(PlanGsonHelper.registerAdapters()))
      .register(LoggingFilter.class)
      .property(ClientProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)
      .property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, true)
      .build();
}
 
Example #10
Source File: TestQueryResource.java    From tajo with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  InetSocketAddress address = testBase.getTestingCluster().getConfiguration().getSocketAddrVar(ConfVars.REST_SERVICE_ADDRESS);
  restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null);
  sessionsURI = new URI(restServiceURI + "/sessions");
  queriesURI = new URI(restServiceURI + "/queries");
  restClient = ClientBuilder.newBuilder()
      .register(new GsonFeature(PlanGsonHelper.registerAdapters()))
      .register(LoggingFilter.class)
      .property(ClientProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)
      .property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, true)
      .build();
}
 
Example #11
Source File: TestTablesResource.java    From tajo with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  InetSocketAddress address = testBase.getTestingCluster().getConfiguration().getSocketAddrVar(ConfVars.REST_SERVICE_ADDRESS);
  restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null);
  tablesURI = new URI(restServiceURI + "/databases/" + defaultDatabaseName + "/tables");
queriesURI = new URI(restServiceURI + "/queries");
sessionsURI = new URI(restServiceURI + "/sessions");
restClient = ClientBuilder.newBuilder()
      .register(new GsonFeature(PlanGsonHelper.registerAdapters()))
      .register(LoggingFilter.class)
      .property(ClientProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)
      .property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, true)
      .build();
}
 
Example #12
Source File: TestQueryResultResource.java    From tajo with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  InetSocketAddress address = testBase.getTestingCluster().getConfiguration().getSocketAddrVar(ConfVars.REST_SERVICE_ADDRESS);
  restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null);
  sessionsURI = new URI(restServiceURI + "/sessions");
  queriesURI = new URI(restServiceURI + "/queries");
  restClient = ClientBuilder.newBuilder()
      .register(new GsonFeature(PlanGsonHelper.registerAdapters()))
      .register(LoggingFilter.class)
      .property(ClientProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)
      .property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, true)
      .build();
}
 
Example #13
Source File: TestClusterResource.java    From tajo with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  InetSocketAddress address = testBase.getTestingCluster().getConfiguration().getSocketAddrVar(ConfVars.REST_SERVICE_ADDRESS);
  restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null);
  clusterURI = new URI(restServiceURI + "/cluster");
  restClient = ClientBuilder.newBuilder()
      .register(new GsonFeature(PlanGsonHelper.registerAdapters()))
      .register(LoggingFilter.class)
      .property(ClientProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)
      .property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, true)
      .build();
}
 
Example #14
Source File: TestDatabasesResource.java    From tajo with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  InetSocketAddress address = testBase.getTestingCluster().getConfiguration().getSocketAddrVar(ConfVars.REST_SERVICE_ADDRESS);
  restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null);
  databasesURI = new URI(restServiceURI + "/databases");
  restClient = ClientBuilder.newBuilder()
      .register(new GsonFeature(PlanGsonHelper.registerAdapters()))
      .register(LoggingFilter.class)
      .property(ClientProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)
      .property(ClientProperties.METAINF_SERVICES_LOOKUP_DISABLE, true)
      .build();
}
 
Example #15
Source File: JerseyConfig.java    From Ratel with Apache License 2.0 5 votes vote down vote up
public JerseyConfig() {
    register(InMemoryDiscoveryServer.class);
    property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, false);
    register(new LoggingFilter(LOGGER, true));
    property(JsonGenerator.PRETTY_PRINTING, true);
    register(JacksonFeature.class);
}
 
Example #16
Source File: ApiApplication.java    From soundwave with Apache License 2.0 5 votes vote down vote up
@Override
public void run(final ApiConfiguration configuration,
                final Environment environment) {

  // Common initializations
  EsInstanceStore cmdbInstanceStore = new EsInstanceStore();
  ServiceMappingStore serviceMappingStore = new EsServiceMappingStore();
  InstanceCounterStore instanceCounterStore = new EsInstanceCounterStore();

  // Health checks
  final EsHealthChecker esHealthChecker = new EsHealthChecker(cmdbInstanceStore);
  environment.healthChecks().register("cmdbStore", esHealthChecker);

  // Logging inbound request/response
  environment.jersey().register(
      new LoggingFilter(java.util.logging.Logger.getLogger("InboundRequestResponse"), true));

  // Add API endpoints here
  final Instance instance = new Instance(cmdbInstanceStore);
  environment.jersey().register(instance);

  final Health health = new Health();
  environment.jersey().register(health);

  final Query query = new Query(cmdbInstanceStore);
  environment.jersey().register(query);

  final InstanceCounter instanceCounter = new InstanceCounter(instanceCounterStore);
  environment.jersey().register(instanceCounter);

  final DailySnapshot dailySnapshot = new DailySnapshot();
  environment.jersey().register(dailySnapshot);
}
 
Example #17
Source File: RestResourceConfig.java    From frameworkAggregate with Apache License 2.0 5 votes vote down vote up
public RestResourceConfig() {
	log.info("-----------------------------loading JERSEY2 restful---------------------------");
 	packages("com.framework.rest.service");
 register(RestAuthRequestFilter.class);
 register(RestResponseFilter.class);
 register(LoggingFilter.class);
 register(JacksonFeature.class);
 register(DeflateEncoder.class);
 EncodingFilter.enableFor(this, GZipEncoder.class);
}
 
Example #18
Source File: ApiClient.java    From connect-java-sdk with Apache License 2.0 5 votes vote down vote up
/**
 * Build the Client used to make HTTP requests.
 * @param debugging Debug setting
 * @return Client
 */
private Client buildHttpClient(boolean debugging) {
  final ClientConfig clientConfig = new ClientConfig();
  clientConfig.register(MultiPartFeature.class);
  clientConfig.register(json);
  clientConfig.register(JacksonFeature.class);
  if (debugging) {
    clientConfig.register(LoggingFilter.class);
  }
  return ClientBuilder.newClient(clientConfig);
}
 
Example #19
Source File: CloudantStoreTest.java    From todo-apps with Apache License 2.0 4 votes vote down vote up
private WebTarget createMockWebTarget() {
  IMocksControl control = createControl();
  WebTarget wt = control.createMock(WebTarget.class);
  expect(wt.register(isA(LoggingFilter.class))).andReturn(wt).anyTimes();
  return wt;
}
 
Example #20
Source File: ExceptionMapperTest.java    From sinavi-jfw with Apache License 2.0 4 votes vote down vote up
public static void configClient(ClientConfig config) {
    config.register(LoggingFilter.class)
        .register(LocaleContextFilter.class)
        .register(ObjectMapperProviderTest.class)
        .register(JacksonFeature.class);
}