Skip to content

Commit

Permalink
Trying to get the example to deploy :(
Browse files Browse the repository at this point in the history
  • Loading branch information
LightGuard committed Nov 18, 2010
1 parent 1bf0fed commit d8a1b91
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 14 deletions.
5 changes: 5 additions & 0 deletions examples/jaxrs/pom.xml
Expand Up @@ -31,6 +31,11 @@

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.seam.xml</groupId>
<artifactId>seam-xml-config</artifactId>
<version>${seam.xml.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
Expand Down
Expand Up @@ -24,15 +24,15 @@

import org.jboss.seam.persistence.SeamManaged;

import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.ConversationScoped;
import javax.enterprise.inject.Produces;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;

public class ManagedPeristenceContextProducer
{
@PersistenceUnit(unitName = "libraryDatabase")
@RequestScoped
@ConversationScoped
@Produces
@SeamManaged
EntityManagerFactory emf;
Expand Down
Expand Up @@ -25,9 +25,10 @@
import org.jboss.seam.exception.control.ExceptionToCatchEvent;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Event;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
Expand All @@ -37,22 +38,24 @@
@ApplicationScoped
public class CatchBridge implements ExceptionMapper<Throwable>
{
@Inject @RestCatch
private Response.ResponseBuilder responseBuilder;
// @Inject @RestCatch
// private Response.ResponseBuilder responseBuilder;

@Inject Event<ExceptionToCatchEvent> event;

@Produces
@RequestScoped
@RestCatch
public Response.ResponseBuilder createErrorResponseBuilder()
{
return Response.serverError();
}
@Inject BeanManager bm;

public Response toResponse(Throwable exception)
{
final Class<Response.ResponseBuilder> responseBuilderType = Response.ResponseBuilder.class;

final Bean<?> bean = this.bm.resolve(this.bm.getBeans(responseBuilderType, RestCatchLiteral.INSTANCE));
final CreationalContext<?> ctx = this.bm.createCreationalContext(bean);
final Response.ResponseBuilder responseBuilder = (Response.ResponseBuilder) this.bm.getReference(bean,
responseBuilderType,
ctx);

event.fire(new ExceptionToCatchEvent(exception, RestCatchLiteral.INSTANCE));
return this.responseBuilder.build();
return responseBuilder.build();
}
}
@@ -0,0 +1,38 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.seam.exception.control.example.jaxrs.handler;

import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
import javax.ws.rs.core.Response;

public class RequestBuilderProducer
{
@Produces
@RequestScoped
@RestCatch
public Response.ResponseBuilder createErrorResponseBuilder()
{
return Response.serverError();
}
}
2 changes: 2 additions & 0 deletions examples/jaxrs/src/main/resources/META-INF/persistence.xml
Expand Up @@ -29,6 +29,8 @@
<jta-data-source>jdbc/__default</jta-data-source>
<properties>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.create-ddl-jdbc-file-name" value="seam-catch-jaxrs-create.sql"/>
<property name="eclipselink.drop-ddl-jdbc-file-name" value="seam-catch-jaxrs-drop.sql"/>
</properties>
</persistence-unit>
</persistence>
Expand Down

0 comments on commit d8a1b91

Please sign in to comment.